package com.ruoyi.web.controller.system.Fdongbei;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.Fdongbei.domain.dibang.GuozhongStats;
import com.ruoyi.system.Fdongbei.domain.vo.reqvo.FapiaochaxunReqVo;
import com.ruoyi.system.Fdongbei.domain.vo.resvo.FapiaochaxunResVo;
import com.ruoyi.system.Fdongbei.service.ITbFapiaojiaoyanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
@RequestMapping("/system/fapiao")
public class TbFapiaojiaoyanController extends BaseController {

    @Autowired
    ITbFapiaojiaoyanService ITbFapiaojiaoyanService;
    /**
     * 兑换统计查询
     */
//    @PreAuthorize("@ss.hasPermi('system:guozhong:list')")
    @GetMapping("/list")
    public TableDataInfo list(GuozhongStats guozhongStats ) {
//        startPage();
        List<GuozhongStats> list = ITbFapiaojiaoyanService.selectTbGuozhongList1(guozhongStats);
        return getDataTable(list);
    }

//    @PreAuthorize("@ss.hasPermi('system:guozhong:list')")
    @GetMapping("/listfuhe")
    public TableDataInfo listfuhe(FapiaochaxunReqVo fapiaochaxunReqVo ) {
//        if (fapiaochaxunReqVo.getCzbh() != null || fapiaochaxunReqVo.getShenhe() != null){
          startPage();
          List<FapiaochaxunResVo> list = ITbFapiaojiaoyanService.selectTbFapiaochzxunList1(fapiaochaxunReqVo);
            return getDataTable(list);
//        }
//        System.out.println("信息查询------》"+fapiaochaxunReqVo.toString());
//        TableDataInfo  tableDataInfo = new TableDataInfo();
//        tableDataInfo.setCode(407);
//        tableDataInfo.setMsg("请输入 审核员 或 单据号 ！！");
//        return tableDataInfo;

    }
    /**
     * 导出tb列表
     */
//    @PreAuthorize("@ss.hasPermi('system:guozhong:export')")
    @Log(title = "tb", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GuozhongStats guozhongStats)
    {
        List<GuozhongStats> list = ITbFapiaojiaoyanService.selectTbGuozhongList1(guozhongStats);
        ExcelUtil<GuozhongStats> util = new ExcelUtil<GuozhongStats>(GuozhongStats.class);
        util.exportExcel(response, list, "tb数据");
    }
}
